function [h] = gngplot(samples, uunit, edges, s_ind, fig_handle)
% Plot samples colorized according to their best matching unit
%
% s_ind ... best matching unit indices (only first col needed)
    
    global COLORS;
    
    if nargin < 5, fig_handle = figure; end 
    h = figure(fig_handle);

    DIM = size(samples,2);
    
    % print samples
    if (size(s_ind) > 0)
        for k = 1:size(uunit,2)
            ind = find(s_ind(:,1)==k);
            switch DIM
              case 2
                plot(samples(ind,1),samples(ind,2),'+','color',COLORS(k,:));
              case 3
                plot3(samples(ind,1),samples(ind,2),samples(ind,3),'+', ...
                      COLORS(k,:));
            end
            hold on;
        end
    end
    
    % print units and edges
    [A B] = find(edges);
    switch DIM
      case 2
        plot(uunit(1,:),uunit(2,:),'k+','markersize',20); %'linew',2
        xx = [uunit(1,A);uunit(1,B)];
        yy = [uunit(2,A);uunit(2,B)];
        line(xx,yy,'color',[0 0 0]);
      case 3
        plot3(uunit(1,:),uunit(2,:),uunit(3,:),'k+','markersize',20),
        xx = [uunit(1,A);uunit(1,B)];
        yy = [uunit(2,A);uunit(2,B)];
        zz = [uunit(3,A);uunit(3,B)];
        line(xx,yy,zz,'color',[0 0 0]);  % 'linew',2);
    end

    axis equal;
    
    %disp('press enter to continue'); pause;
    hold off;
end
